// pages/questions/list.js


const app = getApp();
var utils = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    nav: [
      { id: "1", title: "历年真题", img: "../../images/select.jpg", count: "1234565789" },
      { id: "2", title: "考前押题", img: "../../images/select.jpg", count: "4565789" },
      { id: "3", title: "智能题库", img: "../../images/select.jpg", count: "65789" },
    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    this.getSystemInfo();
    this.getProCate();
  },

  getSystemInfo: function () {
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          height: res.windowHeight,
          width: res.windowHeight
        })
      }
    })
  },

  /*获取产品分类列表*/
  getProCate: function (param) {
    var that = this;
    var sucFunc = function (that, res) {
      //console.log(res.data)
      that.setData({
        // nav: res.data.nav,
        nav: [
          { id: "1", title: "历年真题", img: "../../images/select.jpg", count: "1234565789" },
          { id: "2", title: "考前押题", img: "../../images/select.jpg", count: "4565789" },
          { id: "3", title: "智能题库", img: "../../images/select.jpg", count: "65789" },
          
        ],
        curCate: res.data.curCate,
      })
    }
    var data = {}
    //utils.wxRequest(that, app.d.path, "getProCateList.html", data, sucFunc);
  },

  /*nav点击进入选择试卷或考试*/
  changeCurCate: function (e) {
    var that = this;
    var curCate = e.currentTarget.dataset.id;
    app.d.lianxi = curCate
    if(curCate == 3){
      wx.navigateTo({
        url: "/pages/questions/questions?classId=3&id=0",
      })
    }else{
      wx.navigateTo({
        url: "/pages/questions/lists?id=" + curCate,
      })
    }  
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    app.d.lianxi = 0;
    app.d.jiao = false;
    wx.removeStorage({
      key: 'record',
      success(res) {
        //console.log(res.data)
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})